/*-
 * Copyright (c) 2006, 2007 FTS Team
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 4. Neither the name of the FTS Team nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *      IRConfig.hpp
 *
 * $FTS$
 */
#ifndef _IR_CONFIG_HPP__
#define _IR_CONFIG_HPP__ 1

/**
  @file IRConfig.hpp
  @brief Configuration container for FTSS engine
*/
#include <stdlib.h>

#include <Hash.hpp>
#include <HashFunctions.hpp>
#include <STLString.hpp>

namespace FTSS // FullTextSearchSystem
{

/**
  @class IRConfig IRConfig.hpp <IRConfig.hpp>
  @brief Configuration class for
  @author FTSS Dev. Team. See http://www.tf-idf.org
*/
class IRConfig
{
public:
	/**
	  @brief Constructor
	*/
	IRConfig(const UINT_32 & iKeyCount);

	/**
	  @brief Add pair of (key, value)
	  @param sKey - key
	  @param sValue - value
	  @return 0 if success, -1 if duplicate key found
	*/
	INT_32 AddKey(const STLW::string & sKey, const STLW::string & sValue);

	/**
	  @brief Replace pair of (key, value)
	  @param sKey - key
	  @param sValue - value
	  @return 0 if success, -1 if duplicate key found
	*/
	INT_32 ReplaceKey(const STLW::string & sKey, const STLW::string & sValue);

	/**
	  @brief Get 32-bit integer point value
	  @param sKey - key
	  @param iDefault - default value
	  @return key value or default value if key doesn't exist
	*/
	INT_32 GetInt32(const STLW::string & sKey, const INT_32 & iDefault = 0);

	/**
	  @brief Get 64-bit integer point value
	  @param sKey - key
	  @param iDefault - default value
	  @return key value or default value if key doesn't exist
	*/
	INT_64 GetInt64(const STLW::string & sKey, const INT_64 & iDefault = 0);

	/**
	  @brief Get floating point value
	  @param sKey - key
	  @param dDefault - default value
	  @return key value or default value if key doesn't exist
	*/
	W_FLOAT GetFloat(const STLW::string & sKey, const W_FLOAT & dDefault = 0.0);

	/**
	  @brief Get STLW::string value
	  @param sKey - key
	  @param sDefault - default value
	  @return key value or default value if key doesn't exist
	*/
	const STLW::string & GetString(const STLW::string & sKey, const STLW::string & sDefault = "");

	/**
	  @brief Get Flag
	  @param sKey - key
	  @param iDefault - default value
	  @return key value or default value if key doesn't exist
	*/
	CHAR_8 GetFlag(const STLW::string & sKey, const CHAR_8 & iDefault = 0);

private:
	/** Default constructor   */
	IRConfig();

	/** Default copy operator */
	IRConfig & operator=(const IRConfig & oRhs);

	/**
	  @typedef Pair<TokenHash_t, STLW::string> ConfigPair
	  @brief Index pair type definition
	*/
	typedef Pair<TokenHash_t, STLW::string> ConfigPair;

	/**
	  @typedef Hash<TokenHash_t, STLW::string, HashHasher, HashComparator> ConfigHash
	  @brief Index hash type definition
	*/
	typedef Hash<TokenHash_t, STLW::string, HashHasher, HashComparator> ConfigHash;

	/** Configuration hash      */
	ConfigHash       oConfigHash;
};

} // namespace FTSS
#endif // _IR_CONFIG_HPP__
// End.
